/**
 * 
 * @author libai
 *
 *you can find a num from a Circular array by binary search
 */

public class CircularArray_binaryfind implements Finder {

	public int find(int[] data, int d) {
		/**
		 * the place or the inserted place of the num be printed and returned
		 */
		int length=data.length,high=length-1,low=0,middle;
		while(high>=low)
		{
			middle=(high+low)/2;
			if(data[middle]==d)
			{
				System.out.println("the place is:"+middle);
				return middle;
			}
			else
			{
				if((data[middle]>d)||(data[middle]<d&&data[low]>data[middle]&&d>=data[low]))
					high=middle-1;
				else
					low=middle+1;
			}
		}
		System.out.println("the inserted place is:"+low);
		return low;
	}
	
}
